package cn.tedu;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

/**
 * @Classname: Demo09
 * @Author: bromide
 * @CreateTime: 2022/5/10--10:44
 * @Version: V1.0
 * @Description:
 */
public class Demo09 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入用户名:");
        String username = scanner.nextLine();
        System.out.print("请输入密码:");
        String password = scanner.nextLine();
        System.out.print("请输入昵称:");
        String nick = scanner.nextLine();

        //将得到的3个信息保存到user表中
        try(Connection conn = DBUtils.getConn()) {
            Statement s = conn.createStatement();
            //insert into user values(null,'','','')
            s.executeUpdate("insert into user values (null,'"+username+"','"+password+"','"+nick+"')");
            System.out.println("写入完成!");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}
